#ifndef XWINDOW_H
#define XWINDOW_H

#ifdef XEXPORTING
#define XEXPORT_DLL __declspec(dllexport)
#else
#define XEXPORT_DLL __declspec(dllimport)
#endif

#include <XDraw\XRenderPack.h>
#include <XDraw\XTextPack.h>
#include <XDraw\XTexture.h>
#include <XInput.h>
#include <XMain.h>

class XEXPORT_DLL XWindow
{
protected:
	XHash Hash;
	XRectangle Rectangle;
	XRenderPack* WindowLayout;
	XTextPack* WindowTitle;
	XTexture* Texture;
	XFont* Font;

	std::vector<XRenderPack*> ControlsRender;
	std::vector<XTextPack*> ControlsText;

	bool Active;
	bool Moveable;
	XPosition MousePosition;

	void _loadVertices();
	void _loadTextureVertices();
	void _moveableUpdate(XInputModule* input);
	void _register(XTexture* texture, XFont* font);
public:
	XWindow(XHash hash);
	virtual ~XWindow();

	void SetGeometry(XRectangle rect);
	XRectangle* GetGeometry();
	void SetMoveable(bool moveable);
	bool GetMoveable();

	XFont* GetFont();
	XTexture* GetTexture();
	void RegisterControlsRender(XRenderPack* render);
	void RegisterControlsText(XTextPack* text);

	virtual void Register();
	virtual void Unregister();
	virtual void Update(XInputModule* input);

	friend class XGuiModule;
	friend class XDrawModule;
};

#endif